package com.qezhhnjy.mall.order.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.order.RefundInfo;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.order.service.RefundInfoService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 退款信息 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "退款信息接口")
@Slf4j
@RequestMapping("/refund-info")
public class RefundInfoController {
    @Resource
    private RefundInfoService refundInfoService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取退款信息信息")
    public BaseResult<RefundInfo> get(Long id) {
        RefundInfo refundInfo = refundInfoService.getById(id);
        return BaseResult.success(refundInfo);
    }

    @PostMapping("/save")
    @Operation(summary = "新增退款信息信息")
    public BaseResult<RefundInfo> save(@RequestBody RefundInfo refundInfo) {
        refundInfoService.save(refundInfo);
        return BaseResult.success(refundInfo);
    }

    @PutMapping("/update")
    @Operation(summary = "更新退款信息信息")
    public BaseResult<RefundInfo> update(@RequestBody RefundInfo refundInfo) {
        refundInfoService.updateById(refundInfo);
        return BaseResult.success(refundInfo);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取退款信息信息")
    public BaseResult<Page<RefundInfo>> page(@RequestBody Page<RefundInfo> page) {
        refundInfoService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除退款信息信息")
    public BaseResult<Long> delete(Long id) {
        refundInfoService.removeById(id);
        return BaseResult.success(id);
    }
}

